package com.huilang.demo1;

import java.util.HashMap;

/**
 * @version v1.0
 * @ClassName: BoxFactory
 * @Description: 工厂类，将该类设计为单例
 */
public class BoxFactory {
    private HashMap<String, AbstractBox> map;
    private BoxFactory() {
        map = new HashMap<>();
        map.put("I", new Ibox());
        map.put("O", new Obox());
        map.put("L", new Lbox());
    }

    private static BoxFactory boxFactory = new BoxFactory();
    public static BoxFactory getInstance() {
        return boxFactory;
    }

    public AbstractBox getBox(String type) {
        return map.get(type);
    }

}
